<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<script src="../../../../resources/testharness.js"></script>
<script src="../../../../resources/testharnessreport.js"></script>
<script src="../../../../resources/gesture-util.js"></script>
<style type="text/css">
::-webkit-scrollbar {
  background-color: #ccc;
  height: 15px;
  width: 15px;
}

::-webkit-scrollbar-button {
  display: none;
}

::-webkit-scrollbar-thumb {
  background-color: #777;
  height: 15px;
  width: 15px;
}

#scrollable {
  height: 300px;
  width: 300px;
  overflow: scroll;
}

.large {
  height: 600px;
  width: 600px;
}
</style>
<div id="scrollable">
  <div class="large">
  </div>
</div>

<script type="text/javascript">
var movingDiv = document.getElementById('scrollable');
promise_test (async () => {
  var scrollbarX = movingDiv.offsetLeft + movingDiv.offsetWidth - 5;
  var scrollThumbSafeOffset = 80;
  var scrollbarY = movingDiv.offsetTop + scrollThumbSafeOffset;
  assert_equals(movingDiv.scrollTop, 0);
  await smoothScroll(20, scrollbarX, scrollbarY, GestureSourceType.TOUCH_INPUT,
                     "up", SPEED_INSTANT);
  await waitFor( () => { return movingDiv.scrollTop >= 20;});
  await smoothScroll(60, scrollbarX, scrollbarY, GestureSourceType.TOUCH_INPUT,
                     "up", SPEED_INSTANT);
  await waitFor( () => { return movingDiv.scrollTop >= 85;});
}, 'This tests scroll gesture events on a vertical scroll bar. The ' +
   'scrollable div below should be slightly scrolled down if successful.');

promise_test (async () => {
  var scrollbarY = movingDiv.offsetTop + movingDiv.offsetHeight - 5;
  var scrollThumbSafeOffset = 80;
  var scrollbarX = movingDiv.offsetLeft + scrollThumbSafeOffset;
  assert_equals(movingDiv.scrollLeft, 0);
  await smoothScroll(20, scrollbarX, scrollbarY, GestureSourceType.TOUCH_INPUT,
                     "left", SPEED_INSTANT);
  await waitFor( () => { return movingDiv.scrollLeft >= 20;});
  await smoothScroll(60, scrollbarX, scrollbarY, GestureSourceType.TOUCH_INPUT,
                     "left", SPEED_INSTANT);
  await waitFor( () => { return movingDiv.scrollLeft >= 85; });
}, 'This tests scroll gesture events on a horizontal scroll bar. The ' +
   'scrollable div below should be slightly scrolled right if successful.');
</script>
